From: Andrew Cooper Date: Mon, 8 Jun 2015 12:13:23 +0000 (+0200) Subject: sched_rt: fix memory leak in rt_init() X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3133 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/?a=commitdiff_plain;h=d17547414199f4434289f75ab2b1364cc961982e;p=xen.git sched_rt: fix memory leak in rt_init() Introduced by c/s 376bbba "sched_rt: print useful affinity info when dumping". If the allocation of cpumask failed, prv was leaked. Signed-off-by: Andrew Cooper Coverity-ID: 1304398 Reviewed-by: Dario Faggioli --- diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 5836d274b2..4372486b94 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -441,7 +441,7 @@ rt_init(struct scheduler *ops) { _cpumask_scratch = xmalloc_array(cpumask_var_t, nr_cpu_ids); if ( !_cpumask_scratch ) - return -ENOMEM; + goto no_mem; } nr_rt_ops++; @@ -455,6 +455,10 @@ rt_init(struct scheduler *ops) ops->sched_data = prv; return 0; + + no_mem: + xfree(prv); + return -ENOMEM; } static void